# while循环
# 打印1-10的整数
# 1、循环变量的初始值
# 2、循环的判定条件
# 3、循环变量的更新语句
num = 1
while num <= 10:
    print(num)
    num = num + 1


# 计算1-100的和
sum = 0
num = 1
while num <= 100:
    sum += num
    num += 1
print(f'sum = {sum}')


# 计算 5 的阶乘
result = 1
num = 1
while num <= 5:
    result *= num
    num += 1
print(f'result = {result}')


# 求1！+2！+3！+4！+5！
num = 1
sum = 0
while num <= 5:
    # 先计算出当前 num！是多少，往 sum 上累加
    factorResult = 1
    i = 1
    while i <= num:
        factorResult *= i
        i += 1
    sum += factorResult
    num += 1
print(f'sum = {sum}')